package com.huahang.fashionpress.convert;
import com.huahang.fashionpress.form.FormProduct;
import com.huahang.fashionpress.model.Category;
import com.huahang.fashionpress.model.Product;
import com.huahang.fashionpress.vo.ProductVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 将product对象转换为productVO对象
 * @Author: 阿俊哥
 * @Date: 2019/8/23 18:24
 * @Version 1.0
 */
@Component
public class ProductVOConvertProduct {

    /**
     *
     * @param product
     * @param imgs
     * @return
     */
    public static ProductVO productVOConvertProduct(Product product, List<String> imgs, Category category){


       ProductVO productVO = new ProductVO();
       BeanUtils.copyProperties(product, productVO);
       productVO.setImgs(imgs);
       productVO.setCategory(category);
       return productVO;

    }
    public static FormProduct productFormConvertProduct(Product product){


        FormProduct formProduct = new FormProduct();
        BeanUtils.copyProperties(product, formProduct);
        return formProduct;

    }
}
